<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="t" tagdir="/WEB-INF/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<t:layout title="Step 2 - Instasale">

    <jsp:attribute name="scripts">
        <script>
            $('#used1').click(function () {
                $("#mileageControls").toggle(this.checked);
            });
        </script>
    </jsp:attribute>

    <jsp:body>
        <div class="row">
            <div class="span6 offset3">
                <form:form commandName="car" action="/cars/addFeatures.html">
                    <fieldset>
                        <legend>Choose features:</legend>
                        <form:hidden path="model"/>
                        <form:hidden path="description"/>
                        <form:hidden path="price"/>
                        <form:hidden path="engineType"/>
                        <form:hidden path="seller"/>
                        <form:hidden path="availableDate"/>

                        <div class="checkbox">
                            <form:checkboxes path="features" items="${featuresList}" itemValue="id"
                                             itemLabel="description"/>
                        </div>
                    </fieldset>
                    <fieldset>
                        <legend>Other details:</legend>
                        <label class="checkbox">
                            <form:checkbox path="used"/>
                            Car is used?
                        </label>

                        <div id="mileageControls" style="display: ${car.used ? 'block' : 'none'}">
                            <form:label path="mileage">Specify mileage in km:</form:label>
                            <form:input path="mileage"/>
                            <form:errors path="mileage" cssClass="help-inline" element="span"/>
                        </div>
                    </fieldset>
                    <hr/>
                    <input type="submit"
                           value="Proceed" class="btn btn-success"/>
                </form:form>
            </div>
        </div>
    </jsp:body>
</t:layout>